public class TimerTaskExample {
    public static void main(String[] args) {
        Long start = System.currentTimeMillis();
        for (int i = 1; i <= 5; i++) {
            System.out.println("第 " + i + " 次执行");
            try {
                // 每次执行后休眠1秒
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        Long end = System.currentTimeMillis();
        System.out.println("总共耗时："+(end-start));
    }
}
